package function

class Study() {
  /**
   * 构造主构造器和辅助构造器
   * 创造辅助构造方法前必须先调用主构造方法
   */
  var name: String = _
  var age: Int = _
  println("1主构造方法被调用")

  //申明辅助构造方法
  def this(name: String) {
    this() //直接调用主构造方法
    println("1辅助构造方法被调用")
    this.name = name
    println(s"🚹=${name},age=${age}")

  }

  def this(name: String, age: Int) {
    this()
    println("辅助构造方法被调用")
    this.name = name
    this.age = age
    println(s"🚹=${name},🚺=${age}")
  }
}

object Study {
  def main(args: Array[String]): Unit = {
    //    val study:Study = new Study()
    //    new Study("张三")
    new Study("李四", 25)

  }
}
